package com.hcbd.tdwt.ui.setting.xingyu.activity;


import android.annotation.SuppressLint;
import android.view.View;
import android.widget.RadioButton;
import android.widget.TextView;

import com.hcbd.tdwt.R;
import com.hcbd.tdwt.base.BaseActivity;
import com.hcbd.tdwt.base.Constant;
import com.hcbd.tdwt.base.bd.BdToolFactory;
import com.hcbd.tdwt.util.SharedPreferencesUtil;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

@SuppressLint("NonConstantResourceId")
@EActivity(R.layout.activity_remote_escalation_set)
public class RemoteEscalationSetActivity extends BaseActivity {
    @ViewById
    TextView title;
    @ViewById
    RadioButton hardwareProRb,hardwareA4ProRb,epqRb;
    @ViewById
    RadioButton softwareProRb,software01eeProRb,epqSosRb;

    SharedPreferencesUtil sp;

    private int uploadProVal;
    private int sosProVal;
    @AfterViews
    protected void init() {
        title.setText("远程数据上报协议设置");
        if(BdToolFactory.MOBILE_PHONE_TYPE==BdToolFactory.SATELLITE_MOBILE_PHONE){
            hardwareProRb.setVisibility(View.VISIBLE);
            softwareProRb.setVisibility(View.VISIBLE);
        }
        sp=new SharedPreferencesUtil(this);
        uploadProVal=sp.getAttributeInt(Constant.UPLOAD_PRO);
        sosProVal=sp.getAttributeInt(Constant.SOS_PRO);
//        if(uploadProVal==-1){
//            epqRb.setChecked(true);
//        }else if(uploadProVal==1){
//            hardwareProRb.setChecked(true);
//        }else if(uploadProVal==2){
//            hardwareA4ProRb.setChecked(true);
//        }
        if(uploadProVal==-1){
            hardwareA4ProRb.setChecked(true);
        }else if(uploadProVal==1){
            hardwareProRb.setChecked(true);
        }else if(uploadProVal==2){
            epqRb.setChecked(true);
        }
//        if(sosProVal==-1){
//            epqSosRb.setChecked(true);
//        }else if(sosProVal==1){
//            softwareProRb.setChecked(true);
//        }else if(sosProVal==2){
//            software01eeProRb.setChecked(true);
//        }
        if(sosProVal==-1){
            software01eeProRb.setChecked(true);
        }else if(sosProVal==1){
            softwareProRb.setChecked(true);
        }else if(sosProVal==2){
            epqSosRb.setChecked(true);
        }
    }
    @Click
    void hardwareProRb(){
        sp.addAttribute(Constant.UPLOAD_PRO,1);
    }
    @Click
    void hardwareA4ProRb(){
        sp.addAttribute(Constant.UPLOAD_PRO,-1);
    }
    @Click
    void epqRb(){
        sp.addAttribute(Constant.UPLOAD_PRO,2);
    }
    @Click
    void softwareProRb(){
        sp.addAttribute(Constant.SOS_PRO,1);
    }
    @Click
    void software01eeProRb(){
        sp.addAttribute(Constant.SOS_PRO,-1);
    }
    @Click
    void epqSosRb(){
        sp.addAttribute(Constant.SOS_PRO,2);
    }

    @Click
    void headLeft(){
        finish();
    }


}
